/*
  ID: nemokin1
  PROG: ttwo
  LANG: C++
*/
#include <vector>
#include <list>
#include <assert.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <fstream>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
 
using namespace std;
 
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
 
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a)  (int(a.size()))
 
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef long double ld;
const int INF = 1000000000;

int rx[4] = {-1,0,1,0};
int ry[4] = {0,1,0,-1};

int main() {
    freopen("ttwo.in","r",stdin);freopen("ttwo.out","w",stdout);
    char rr[10][10];
    int visited[10][10][4][10][10][4];
    memset(visited,0,sizeof(visited));
    
    for(int i = 0; i < 10; i++){
	for(int j = 0; j < 10; j++){
	    char c;
	    cin >> c;
	    rr[i][j] = c;
	}
    }
    int fx,fy,cx,cy;
    for(int i = 0; i < 10; i++){
	for(int j = 0; j < 10; j++){
	    if(rr[i][j] == 'C'){
		cx=i;
		cy=j;
	    }
	    else if(rr[i][j] == 'F'){
		fx=i;
		fy=j;
	    }
	}
    }
    int dirf=0,dirc=0;
    int cnt = 0;
    
    for(;;){
	//cout<<"("<<fx<<","<<fy<<")"<<"("<<cx<<","<<cy<<")"<<endl;
	if(fx==cx && fy==cy) {cout<<cnt<<endl;exit(0);}
	if(visited[fx][fy][dirf][cx][cy][dirc]) {cout<<"0"<<endl;exit(0);}
	cnt++;
	visited[fx][fy][dirf][cx][cy][dirc] = 1;
	if(fx+rx[dirf]<0||fx+rx[dirf]>=10
	   ||fy+ry[dirf]<0||fy+ry[dirf]>=10
	   ||rr[fx+rx[dirf]][fy+ry[dirf]] == '*'){
	    dirf=(dirf+1)%4;
	}
	else{
	    fx+=rx[dirf];
	    fy+=ry[dirf];
	}
	if(cx+rx[dirc]<0||cx+rx[dirc]>=10
	   ||cy+ry[dirc]<0||cy+ry[dirc]>=10
	   ||rr[cx+rx[dirc]][cy+ry[dirc]] == '*'){
	    dirc=(dirc+1)%4;
	}
	else{
	    cx+=rx[dirc];
	    cy+=ry[dirc];
	}
    }
}

    

